function initTable() {
    ajaxCall("POST","../SelfServlet?method=getTable",setTable)
}
function setTable(res) {
    var obj=JSON.parse(res);
    var table=document.getElementById("t1");
    for(var i in obj){
        var newRow=table.insertRow(1);
        var date=newRow.insertCell(0);
        var selfExamId=newRow.insertCell(1);
        var classId=newRow.insertCell(2);
        var winner=newRow.insertCell(3);
        var whenClick=newRow.insertCell(4);

        date.innerHTML=obj[i].date;
        selfExamId.innerHTML=obj[i].questionId;
        classId.innerHTML=obj[i].classId;
        winner.innerHTML=obj[i].winnerId;
        whenClick.innerHTML="<input type='button' value='详情' onclick='details(this)'/>"

    }

}
function details(row) {
    var rowIndex=row.parentNode.parentNode.rowIndex;
    var table=document.getElementById("t1");
    var date=table.rows[rowIndex].cells[0].innerHTML;
    window.location.href="historyComDetails.jsp?date="+date;
}
function ajaxCall(method,url,callBackFunction){
    var httprequest=new XMLHttpRequest();
    httprequest.onreadystatechange=function(){
        if(httprequest.readyState==4&&httprequest.status==200){
            callBackFunction(httprequest.responseText);
        }
    }
    httprequest.open(method,url,false);
    httprequest.send();
}